/**
 *测试递归
 */

public class TestRecurse {
    public static void main(String[] args){
        long startTime = System.currentTimeMillis();
        long result = factorial(5);
        long endTime = System.currentTimeMillis();
        System.out.println(result);
        System.out.println("递归耗时："+(endTime-startTime));
    }

    //5*4*3*2*1
    public static long factorial(int n){
        if (n==1){
            return 1;
        }else {
            return n*factorial(n-1);
        }
    }
}
